//package cn.hznc.security;
//
//import cn.hznc.domain.entity.UserEntity;
//import cn.hznc.repository.UserRepository;
//import cn.hznc.service.UserService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @Author：Administrator
// * @Date：2023/5/22 16:21
// */
//@Component
//public class UserDetailServiceImpl implements UserDetailsService{
//
//    @Resource
//    private UserRepository userRepository;
//
//    @Override
//    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//        UserEntity userEntity = userRepository.selectbyname(username);
//        if (null == userEntity){
//            //账户错误 , 登录失败
//            return null;
//        }
//        //账户正确
//        List<SimpleGrantedAuthority> authorities = new ArrayList<>();
//        return new User(userEntity.getUsername(), userEntity.getPassword(), authorities);
//    }
//}
